﻿@using Kevin.Shop.Business.Service.Entity.Helper
@using RiderShop.Mobile.Common.Component

@model RiderShop.Mobile.Modle.Product.ProductListModel
@{
    ViewBag.Title = "商品列表";
}
<div class="products">
    @{ Html.RenderAction("SearchPartial", "Home"); }
    <!-- InstanceBeginEditable name="Body" -->

    @if (Model.Result.Data.Count == 0)
    {
        <div class="noresult">
            <h1>十分抱歉，我们没有找到与 <strong class="red">"@Model.Keyword"</strong>的相关的商品</h1>
            <p>1、看看输入的文字是否有误</p>
            <p>
                2、可尝试对搜索关键词根据其词义来进行拆分，输入多个词语搜索，可以获得更精确的搜索结果。<br>
                <span class="blue">例如：搜索“恢复肠道”，可以改为搜索“恢复 肠道”</span>
            </p>
        </div>
    }
    else
    {
        <form action="~/Product/ProductList" id="productList">
            <select name="SortField" id="SortField" category="@Model.SubcategoryCode">
                @foreach (var item in Model.SearchCondition)
                {
                    if (Model.FiterIndex == item.Value)
                    {
                    <option value="@item.Value" selected="selected">@item.Key</option>
                    }
                    else
                    {
                    <option value="@item.Value">@item.Key</option>
                    }
                }
            </select>
        </form>
    }
    @foreach (var item in Model.Result.Data)
    {
        <div class="groupbox ">
            <div class="ItemTable ">
                <div class="ItemTableRight productList">
                    <div class="OtherProductItem ">
                        <a href="~/Product/ProductDetail?prd=@item.ProductId" class="ui-link">
                            <div class="ItemLeft">
                                <div class="iconPromB">
                                    @if (!string.IsNullOrEmpty(@item.PromotionTypeStr))
                                    {
                                        <img src="@item.PromotionTypeIcon" alt="" />
                                    }
                                </div>
                                <img alt="" src="@item.ActualImageUrl" alt="@item.Title" />
                            </div>
                            <div class="ItemRight">
                                <h2 class="title">@item.Title</h2>
                                <div class="viewdesc ml10 mb5 normalwrap">
                                    @Html.Raw(@item.ViewDescription)
                                </div>
                                <div class="price f14">￥@item.UnitPrice</div>
                                <div class="koubei ml5">
                                    <span class="fl">已有(@item.ReviewCount)人评价</span>
                                    <span class="rating fl"><span style="width:@item.ReviewCount%" class="value"></span></span>
                                </div>
                            </div>
                        </a>
                    </div>
                </div>
            </div>
        </div>

    }
    <div>@Html.Pagination(WebClientContext.Current.PageSize, Model.PageIndex, Model.Result.TotalRecords, null)</div>
</div>
<script language="javascript" type="text/javascript">
    $(document).ready(function () {
        $("#SortField").change(function () {
            var seelctIndex = $(this).children('option:selected').val();
            var category = $("#SortField").attr("category");
            var par = "";
            switch (seelctIndex) {
                case "1"://lower unit price
                    par = "&sort=1&order=7";
                    break;
                case "2"://most review
                    par = "&sort=0&order=2";
                    break;
                case "3"://up unit price
                    par = "&sort=1&order=0";
                    break;
                case "4"://up unit price
                    par = "&sort=0&order=0";
                    break;
                case "5"://active date
                    par = "&sort=0&order=1";
                    break;
                default:
            }
            var url = document.forms["productList"].action;
            window.location = url + "?findex=" + seelctIndex + "&count=" + category + "&sid=" + category + par;
        });
    });
</script>
